from re import split

from flask import Flask, Blueprint
from injector import inject
from dataclasses import dataclass
from src.handler import AppHandler,ExercisesHandler,UserHandler


@inject
@dataclass
class Router:
    app_handler: AppHandler
    exercises_handler: ExercisesHandler
    user_handler: UserHandler
    def reg_router(self, app: Flask):
        bp = Blueprint("api", __name__, url_prefix="")
        bp.add_url_rule("/chat", methods=["post"],view_func=self.app_handler.chat)
        bp.add_url_rule("/uploadFile",methods=["post"],view_func=self.app_handler.upload_file)
        bp.add_url_rule("/sim",view_func=self.app_handler.sim)
        bp.add_url_rule("/audioToText",methods=["post"],view_func=self.app_handler.audio_text)
        bp.add_url_rule("/textAudio",view_func=self.app_handler.text_audio)
        bp.add_url_rule("/select_sub",methods=["post"],view_func=self.exercises_handler.select_sub)
        bp.add_url_rule("/add_all",methods=["post"],view_func=self.exercises_handler.add_all)
        bp.add_url_rule("/login",methods=["post"],view_func=self.user_handler.login)
        bp.add_url_rule("/getuser_info",methods=["post"],view_func=self.user_handler.getuser_info)
        bp.add_url_rule("/register", methods=["post"], view_func=self.user_handler.register)
        bp.add_url_rule("/answer", methods=["post"], view_func=self.exercises_handler.answer)
        bp.add_url_rule("/get_random_categories", view_func=self.exercises_handler.get_random_categories)
        bp.add_url_rule("/get_question", methods=["post"], view_func=self.exercises_handler.get_question)
        bp.add_url_rule("/exit", methods=["post"], view_func=self.exercises_handler.exit)
        bp.add_url_rule("/try_gen", methods=["post"], view_func=self.exercises_handler.try_gen)
        bp.add_url_rule("/try_user_gen",methods=["post"], view_func=self.exercises_handler.try_user_gen)
        bp.add_url_rule("/get_question_sign", methods=["post"], view_func=self.exercises_handler.get_question_sign)
        bp.add_url_rule("/get_user_question_sign", methods=["post"], view_func=self.exercises_handler.get_user_question_sign)
        bp.add_url_rule("/sucees_list", view_func=self.exercises_handler.sucees_list)
        bp.add_url_rule("/fil_list",view_func=self.exercises_handler.fil_list)
        bp.add_url_rule("/create_category",methods=["post"], view_func=self.exercises_handler.create_category)
        bp.add_url_rule("/get_week_success_task",view_func=self.exercises_handler.get_week_success_task)
        bp.add_url_rule("/get_week_user_success_task",view_func=self.exercises_handler.get_week_user_success_task)
        bp.add_url_rule("/get_moth_count",view_func=self.exercises_handler.get_moth_count)
        bp.add_url_rule("/today",view_func=self.exercises_handler.today)
        bp.add_url_rule("/study_days",view_func=self.exercises_handler.study_days)
        bp.add_url_rule("/answer_sum",view_func=self.exercises_handler.answer_sum)
        bp.add_url_rule("/sum_success_rate",view_func=self.exercises_handler.sum_success_rate)
        bp.add_url_rule("/error_replay",view_func=self.exercises_handler.error_replay)
        bp.add_url_rule("/error_user_replay",view_func=self.exercises_handler.error_user_replay)
        bp.add_url_rule("/success_count",view_func=self.exercises_handler.success_count)
        bp.add_url_rule("/time_view",view_func=self.exercises_handler.time_view)
        bp.add_url_rule("/upload_img", methods=["post"],view_func=self.app_handler.upload_img)
        bp.add_url_rule("/get_score",view_func=self.exercises_handler.get_score)
        bp.add_url_rule("/end",view_func=self.exercises_handler.end)
        bp.add_url_rule("/getTimeScore",view_func=self.exercises_handler.getTimeScore)
        bp.add_url_rule("/error_list",view_func=self.exercises_handler.error_list)
        bp.add_url_rule("/getCategoryList",view_func=self.exercises_handler.getCategoryList)
        bp.add_url_rule("/getScoreSum",view_func=self.exercises_handler.getScoreSum)
        bp.add_url_rule("/calculate_percentages_for_user",view_func=self.exercises_handler.calculate_percentages_for_user)
        bp.add_url_rule("/audioUploads/<string:exercise_id>", methods=["post"],view_func=self.exercises_handler.audio_uploads)
        bp.add_url_rule("/chatAudioUpload", methods=["post"],
                        view_func=self.exercises_handler.chat_audio_upload)
        bp.add_url_rule("/getAudioUrl",view_func=self.exercises_handler.get_audio_url)
        bp.add_url_rule("/user_category", methods=["post"],view_func=self.exercises_handler.user_category)
        bp.add_url_rule("/fil_user_list",view_func=self.exercises_handler.fil_user_list)
        bp.add_url_rule("/success_user_list",view_func=self.exercises_handler.sucees_user_list)
        bp.add_url_rule("/answer_user", methods=["post"],view_func=self.exercises_handler.user_answer)
        bp.add_url_rule("/get_user_question",methods=["post"], view_func=self.exercises_handler.get_user_question)
        bp.add_url_rule("/get_source_chart",view_func=self.exercises_handler.get_source_chart)
        bp.add_url_rule("/get_category_scores",view_func=self.exercises_handler.get_category_scores)
        bp.add_url_rule("/createCategory",methods=["post"],view_func=self.exercises_handler.create_category)
        bp.add_url_rule("/del_fil_list",view_func=self.exercises_handler.del_fil_list)
        bp.add_url_rule("/del_fil_user_list",view_func=self.exercises_handler.del_fil_user_list)
        app.register_blueprint(bp)
